﻿using System;

class Sample
{
    protected static int origRow;
    protected static int origCol;

    protected static void WriteAt(string s, int x, int y)
    {
        try
        {
            Console.SetCursorPosition(origCol + x, origRow + y);
            Console.Write(s);
        }
        catch (ArgumentOutOfRangeException e)
        {
            Console.Clear();
            Console.WriteLine(e.Message);
        }
    }

    public static void Main()
    {
        Console.Clear();
        origRow = Console.CursorTop;
        origCol = Console.CursorLeft;
        for (int y=0;y<120;y++)
        {
            WriteAt("#", 0, y);
        }
        for (int x = 0; x < Console.WindowWidth; x++)
        {
            WriteAt("#", x, 0);
        }
        for (int x = Console.WindowWidth-1; x > 0; x--)
        {
            WriteAt("#", x, 119);
        }
        for (int y = 119; y > 0; y--)
        {
            WriteAt("#",Console.WindowWidth - 1, y);
        }
        ConsoleKeyInfo k;
        Console.WriteLine();
        GetConsoleScreenBufferInfo();
        Console.Write("{0}", k.Key);
        Console.ReadKey();
    }
}